<template>
  <nav>
    <router-link to="/">首页</router-link>
    <router-link to="/public-activities">公开活动</router-link>
    <router-link v-if="isAdmin" to="/activity-management">活动管理</router-link>
    <button @click="logout">退出</button>
  </nav>
</template>

<script>
export default {
  computed: {
    isAdmin() {
      const user = JSON.parse(localStorage.getItem('user'))
      return user && user.role === 'admin'
    }
  },
  methods: {
    logout() {
      localStorage.removeItem('user')
      this.$router.push('/login')
    }
  }
}
</script>